home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / Meshwriter_lib / Library / samples / checkboard.c next >
C/C++ Source or Header  |  1999-12-03  |  3KB  |  88 lines

  1. /*
  2. **      $VER: checkboard.c 1.00 (20.3.1999)
  3. **
  4. **      Creation date     : 20.3.1999
  5. **
  6. **      Description       :
  7. **         MeshWriter testprogram shape module.
  8. **
  9. **
  10. **      Written by Stephan Bielmann
  11. **
  12. */
  13.  
  14. /*************************** Includes *******************************/
  15.  
  16. #include <meshwriter/meshwriter.h>
  17. #include <pragma/meshwriter_lib.h>
  18.  
  19. /**************************** Defines *******************************/
  20.  
  21. /*********************** Type definitions ***************************/
  22.  
  23. /********************** Private functions ***************************/
  24. static void drawFace(ULONG mesh, ULONG color) {
  25.   TOCLVertex v1,v2,v3,v4;
  26.  
  27.   v1.x=-0.5,v1.y=-0.5,v1.z=0;
  28.   v2.x=0.5,v2.y=-0.5,v2.z=0;
  29.   v3.x=0.5,v3.y=0.5,v3.z=0;
  30.   v4.x=-0.5,v4.y=0.5,v4.z=0;
  31.   
  32.   MWLMeshTriangleAdd(mesh,color,&v1,&v2,&v3);
  33.   MWLMeshTriangleAdd(mesh,color,&v1,&v3,&v4);
  34. }
  35.  
  36. /********************** Public functions ****************************/
  37.  
  38. /********************************************************************\
  39. *                                                                    *
  40. * Name         : checkboard                                          *
  41. *                                                                    *
  42. * Description  : Draws a black/white checkboard. With the help of    *
  43. *                the translation function.                           *
  44. *                                                                    *
  45. * Arguments    : mesh    IN  : An initialized mesh handle.           *
  46. *                                                                    *
  47. * Comment      :                                                     *
  48. *                                                                    *
  49. \********************************************************************/
  50. void checkboard(ULONG mesh) {
  51.   ULONG black,white,i,j;
  52.   TOCLColor color;
  53.   TOCLVertex vt;
  54.  
  55.  
  56.   MWLMeshMaterialAdd(mesh,&black);
  57.   color.r=0,color.g=0,color.b=0;
  58.   MWLMeshMaterialDiffuseColorSet(mesh,black,&color);
  59.   MWLMeshMaterialNameSet(mesh,black,"black");
  60.   MWLMeshMaterialShininessSet(mesh,black,0);
  61.   MWLMeshMaterialTransparencySet(mesh,black,0);
  62.  
  63.   MWLMeshMaterialAdd(mesh,&white);
  64.   color.r=255,color.g=255,color.b=255;
  65.   MWLMeshMaterialDiffuseColorSet(mesh,white,&color);
  66.   MWLMeshMaterialNameSet(mesh,white,"white");
  67.   MWLMeshMaterialShininessSet(mesh,white,0);
  68.   MWLMeshMaterialTransparencySet(mesh,white,0);
  69.  
  70.   MWLMeshNameSet(mesh,"Checkboard");
  71.  
  72.   vt.z=0;
  73.  
  74.   for(i=0;i<8;i++) {
  75.     for(j=0;j<8;j++) {
  76.       vt.x=i,vt.y=j;
  77.       MWLMeshTranslationChange(mesh,&vt,CTMSET);
  78.       if((i+j)%2) {
  79.         drawFace(mesh,black);
  80.       } else {
  81.         drawFace(mesh,white);
  82.       }
  83.     }
  84.   }
  85. }
  86.  
  87. /************************* End of file ******************************/
  88.